using System.Collections.Generic;
using System.Linq;

namespace OpenWaves.ActivityFeed.Web
{
    [DefaultImplementation(typeof(HttpContextBasedUserGroupMembershipProvider))]
    public interface IUserGroupMembershipProvider
    {
        IEnumerable<UserGroup> UserGroups { get; }        
    }

    public class CompositeUserGroupMembershipProvider : IUserGroupMembershipProvider
    {
        private readonly IUserGroupMembershipProvider[] providers;

        public CompositeUserGroupMembershipProvider(params IUserGroupMembershipProvider[] providers)
        {
            this.providers = providers;
        }

        public IEnumerable<UserGroup> UserGroups
        {
            get { return this.providers.SelectMany(p => p.UserGroups); }
        }
    }
}